"""
优惠券信息DTO

@author liaochangyi
@since 2025-01-25
"""

from typing import Dict, Any


class CouponInfoDto:
    """优惠券信息DTO"""
    
    def __init__(self, coupon_dict=None):
        """
        初始化优惠券信息
        
        Args:
            coupon_dict: 优惠券信息字典
        """
        self.promotion_id = None  # 券ID
        self.name = None  # 优惠名称
        self.scope = None  # 优惠范围
        self.type = None  # 优惠类型
        self.amount = None  # 优惠券面额
        self.activity_id = None  # 活动ID
        self.wxpay_contribute = None  # 微信出资
        self.merchant_contribute = None  # 商户出资
        self.id = None  # 支付宝券ID
        self.other_contribute = None  # 其他出资金额
        self.memo = None  # 备注信息
        self.template_id = None  # 券模板ID
        self.other_contribute_detail = None  # 优惠券的其他出资方明细
        self.purchase_buyer_contribute = None  # 买家出资
        self.purchase_merchant_contribute = None  # 商户出资
        self.purchase_ant_contribute = None  # 内部出资
        self.spnsr_id = None  # 出资方
        self.offst_amt = None  # 优惠金额
        self.desc = None  # 项目简称
        self.addn_info = None  # 附加信息
        self.issuer_id = None  # 项目发行方
        
        if coupon_dict:
            self.promotion_id = coupon_dict.get('promotion_id')
            self.name = coupon_dict.get('name')
            self.scope = coupon_dict.get('scope')
            self.type = coupon_dict.get('type')
            self.amount = coupon_dict.get('amount')
            self.activity_id = coupon_dict.get('activity_id')
            self.wxpay_contribute = coupon_dict.get('wxpay_contribute')
            self.merchant_contribute = coupon_dict.get('merchant_contribute')
            self.id = coupon_dict.get('id')
            self.other_contribute = coupon_dict.get('other_contribute')
            self.memo = coupon_dict.get('memo')
            self.template_id = coupon_dict.get('template_id')
            self.other_contribute_detail = coupon_dict.get('other_contribute_detail')
            self.purchase_buyer_contribute = coupon_dict.get('purchase_buyer_contribute')
            self.purchase_merchant_contribute = coupon_dict.get('purchase_merchant_contribute')
            self.purchase_ant_contribute = coupon_dict.get('purchase_ant_contribute')
            self.spnsr_id = coupon_dict.get('spnsr_id')
            self.offst_amt = coupon_dict.get('offst_amt')
            self.desc = coupon_dict.get('desc')
            self.addn_info = coupon_dict.get('addn_info')
            self.issuer_id = coupon_dict.get('issuer_id')
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        return {
            'promotion_id': self.promotion_id,
            'name': self.name,
            'scope': self.scope,
            'type': self.type,
            'amount': self.amount,
            'activity_id': self.activity_id,
            'wxpay_contribute': self.wxpay_contribute,
            'merchant_contribute': self.merchant_contribute,
            'id': self.id,
            'other_contribute': self.other_contribute,
            'memo': self.memo,
            'template_id': self.template_id,
            'other_contribute_detail': self.other_contribute_detail,
            'purchase_buyer_contribute': self.purchase_buyer_contribute,
            'purchase_merchant_contribute': self.purchase_merchant_contribute,
            'purchase_ant_contribute': self.purchase_ant_contribute,
            'spnsr_id': self.spnsr_id,
            'offst_amt': self.offst_amt,
            'desc': self.desc,
            'addn_info': self.addn_info,
            'issuer_id': self.issuer_id
        } 